﻿Public Class MaterialShapeForm

    Public Switch As Boolean = True  'True: マージンを指定/ False：サイズを指定

    Public XPositive As Double
    Public XNegative As Double
    Public YPositive As Double
    Public YNegative As Double
    Public ZPositive As Double
    Public ZNegative As Double

    Public XSize As Double
    Public YSize As Double
    Public ZSize As Double
    Public XPosition As Double
    Public YPosition As Double
    Public ZPosition As Double

    'マージンを選択する場合（サイズの選択を不可に）
    Private Sub RadioButtonMargin_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButtonMargin.CheckedChanged
        If RadioButtonMargin.Checked Then
            'RadioButtonMaterialShape.Checked = False
            LabelXPositive.Enabled = True
            LabelXNegative.Enabled = True
            LabelYPositive.Enabled = True
            LabelYNegative.Enabled = True
            LabelZPositive.Enabled = True
            LabelZNegative.Enabled = True
            TextBoxXPositive.Enabled = True
            TextBoxXNegative.Enabled = True
            TextBoxYPositive.Enabled = True
            TextBoxYNegative.Enabled = True
            TextBoxZPositive.Enabled = True
            TextBoxZNegative.Enabled = True

        Else
            'RadioButtonMaterialShape.Checked = True
            LabelXPositive.Enabled = False
            LabelXNegative.Enabled = False
            LabelYPositive.Enabled = False
            LabelYNegative.Enabled = False
            LabelZPositive.Enabled = False
            LabelZNegative.Enabled = False
            TextBoxXPositive.Enabled = False
            TextBoxXNegative.Enabled = False
            TextBoxYPositive.Enabled = False
            TextBoxYNegative.Enabled = False
            TextBoxZPositive.Enabled = False
            TextBoxZNegative.Enabled = False

        End If
    End Sub

    'サイズを選択する場合（マージンの選択を不可に）
    Private Sub RadioButtonMaterialShape_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButtonMaterialShape.CheckedChanged
        If RadioButtonMaterialShape.Checked Then
            'RadioButtonMargin.Checked = False
            LabelSize.Enabled = True
            LabelPosition.Enabled = True
            LabelXSize.Enabled = True
            LabelYSize.Enabled = True
            LabelZSize.Enabled = True
            LabelXPosition.Enabled = True
            LabelYPosition.Enabled = True
            LabelZPosition.Enabled = True
            TextBoxXSize.Enabled = True
            TextBoxYSize.Enabled = True
            TextBoxZSize.Enabled = True
            TextBoxXPosition.Enabled = True
            TextBoxYPosition.Enabled = True
            TextBoxZPosition.Enabled = True

        Else
            LabelSize.Enabled = False
            LabelPosition.Enabled = False
            LabelXSize.Enabled = False
            LabelYSize.Enabled = False
            LabelZSize.Enabled = False
            LabelXPosition.Enabled = False
            LabelYPosition.Enabled = False
            LabelZPosition.Enabled = False
            TextBoxXSize.Enabled = False
            TextBoxYSize.Enabled = False
            TextBoxZSize.Enabled = False
            TextBoxXPosition.Enabled = False
            TextBoxYPosition.Enabled = False
            TextBoxZPosition.Enabled = False

        End If
    End Sub

    'ダンボークリック時の挙動（テスト用）
    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        TextBoxXPositive.Text = "0"
        TextBoxXNegative.Text = "0"
        TextBoxYPositive.Text = "0"
        TextBoxYNegative.Text = "0"
        TextBoxZPositive.Text = "10"
        TextBoxZNegative.Text = "0"
        RadioButtonMargin.Checked = True
        TextBoxXSize.Text = "100"
        TextBoxYSize.Text = "100"
        TextBoxZSize.Text = "100"
        TextBoxXPosition.Text = "-50"
        TextBoxYPosition.Text = "-50"
        TextBoxZPosition.Text = "-50"
    End Sub

    'OKボタンの挙動（値を取得してフォームを閉じる）
    Private Sub ButtonOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOK.Click
        If RadioButtonMargin.Checked Then
            Switch = True
        Else
            Switch = False
        End If

        If Switch Then
            XPositive = CDbl(TextBoxXPositive.Text)
            XNegative = CDbl(TextBoxXNegative.Text)
            YPositive = CDbl(TextBoxYPositive.Text)
            YNegative = CDbl(TextBoxYNegative.Text)
            ZPositive = CDbl(TextBoxZPositive.Text)
            ZNegative = CDbl(TextBoxZPositive.Text)
        Else
            XSize = CDbl(TextBoxXSize.Text)
            YSize = CDbl(TextBoxYSize.Text)
            ZSize = CDbl(TextBoxZSize.Text)
            XPosition = CDbl(TextBoxXPosition.Text)
            YPosition = CDbl(TextBoxYPosition.Text)
            ZPosition = CDbl(TextBoxZPosition.Text)
        End If


        Me.Close()

    End Sub

    Private Sub MaterialShapeForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        RadioButtonMargin.Checked = True
    End Sub
End Class